﻿using Newtonsoft.Json;
using System;

namespace T.FAS.Runtime.Metadata.Entity.DataModel
{
    /// <summary>
    /// 数据查询-过滤条件
    /// </summary>
    [Serializable]
    public class DataQueryFilter :System.ICloneable
    {
        /// <summary>
        /// 主键id
        /// </summary>
        public string ID { get; set; }

        /// <summary>
        /// 数据查询id
        /// </summary>
        public string DataQueryID { get; set; }

        /// <summary>
        /// 条件表达式
        /// </summary>
        public string FilterExpression { get; set; }

        /// <summary>
        /// 条件表达式Json
        /// </summary>
        public string FilterExpressionJson { get; set; }

        /// <summary>
        /// 普通条件&聚合条件
        /// </summary>
        public FilterType FilterType { get; set; }

        /// <summary>
        /// true:系统默认条件，false:用户自定义条件
        /// </summary>
        public bool IsDefault { get; set; }

        /// <summary>
        /// 排序
        /// </summary>
        public int Sort { get; set; }

        /// <summary>
        /// 备用字段
        /// </summary>
        [JsonIgnore]
        public string Ext1 { get; set; }

        /// <summary>
        /// 备用字段
        /// </summary>
        [JsonIgnore]
        public string Ext2 { get; set; }

        /// <summary>
        /// 备用字段
        /// </summary>
        [JsonIgnore]
        public string Ext3 { get; set; }

        /// <summary>
        /// 创建人
        /// </summary>
        [JsonIgnore]
        public string Creator { get; set; }

        /// <summary>
        /// 创建时间
        /// </summary>        
        [JsonIgnore]
        public DateTime CreateTime { get; set; }

        /// <summary>
        /// 最后修改人
        /// </summary>
        [JsonIgnore]
        public string LastModifier { get; set; }

        /// <summary>
        /// 最后修改时间
        /// </summary>        
        [JsonIgnore]
        public DateTime LastModifyTime { get; set; }

        public object Clone()
        {
            return this.MemberwiseClone();
        }
    }

    public enum FilterType
    {
        /// <summary>
        /// 普通条件
        /// </summary>
        Normal=0, 
        /// <summary>
        /// 聚合条件
        /// </summary>
        Aggregate=1,
    }
}
